package cn.terminus.data.customer.customdemandarea.impl;

import cn.terminus.common.customer.bean.customdemandarea.dto.*;
import cn.terminus.data.customer.customdemandarea.dao.CustomDemandAreaDao;
import cn.terminus.data.customer.customdemandarea.mapper.CustomDemandAreaMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomDemandArea)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:47
 */
@Repository
public class CustomDemandAreaDaoImpl implements CustomDemandAreaDao {
    @Resource
    private CustomDemandAreaMapper customDemandAreaMapper;

    @Override
    public Integer add(CustomDemandAreaNewDto dto) {
        return customDemandAreaMapper.add(dto);
    }

    @Override
    public Integer update(CustomDemandAreaEditDto dto) {
        return customDemandAreaMapper.update(dto);
    }

    @Override
    public List<CustomDemandAreaResultDto> gets(CustomDemandAreaGetsDto dto) {
        return customDemandAreaMapper.gets(dto);
    }

    @Override
    public List<CustomDemandAreaResultDto> query(CustomDemandAreaQueryDto dto) {
        return customDemandAreaMapper.query(dto);
    }

    @Override
    public Integer delete(CustomDemandAreaDeleteDto dto) {
        return customDemandAreaMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomDemandAreaResultDto> page(CustomDemandAreaQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomDemandAreaResultDto> result = (Page<CustomDemandAreaResultDto>) customDemandAreaMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomDemandAreaResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer addMulti(List<CustomDemandAreaNewDto> areaNewDtoList) {
        return customDemandAreaMapper.addMulti(areaNewDtoList);
    }
}
